home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16054 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  5.6 KB

  1. Path: news.cyberport.com!usenet
  2. From: tangent@cyberport.com (Warren Young)
  3. Newsgroups: comp.lang.c++,rec.games.programmer,alt.msdos.programmer,comp.programming
  4. Subject: Re: Young programmers read me.
  5. Date: Tue, 09 Apr 1996 09:52:51 GMT
  6. Organization: none
  7. Message-ID: <316a2987.3677177@news.cyberport.com>
  8. References: <4icpp9$7hr@barad-dur.nas.com> <4imqe4$cj3@ping1.ping.be> <1996Mar23.224853.116513@kuhub.cc.ukans.edu> <4j52hn$ikb@news.ios.com> <Pine.OSF.3.91.960403112207.17337H-100000@bud.cc.swin.edu.au> <aidan-0404961557290001@meathook.intac.com> <pnoguchi-0404962135210001@pnoguchi.his.com> <aidan-0604961847480001@meathook.intac.com>
  9. NNTP-Posting-Host: ppp5.cyberport.com
  10. X-Newsreader: Forte Agent .99d/32.182
  11.  
  12. aidan@genghis.kublai.com (Aidan Cully) wrote:
  13.  
  14. >programming and speed, I was only arguing that Pascal has certain things
  15. >over it (e.g. readability and honest-to-God free-form language), and just
  16.  
  17. Pascal is one of the least free-form languages I know (old Fortran
  18. being the glaring exception, of course).  Consider declaration blocks:
  19. they have to go in a very specific order, and for no really good
  20. reason.  Sure, most modern Pascals throw this rule to the wind, but
  21. that's how it was designed.
  22.  
  23. I've only seen one argument from you about C's "non-free-form"
  24. attributes, and that was the #define statement.  As someone already
  25. pointed out, it's not really part of the language anyway.  Besides,
  26. C++ fixes that with true constants and inline functions.  Very little
  27. is lost by using these new features to the complete exclusion of
  28. #define.
  29.  
  30. As for readability: that's subjective.  I can think of any number of
  31. things that are "readable" only to people trained in their
  32. intricacies.  Electrical schematics, for one example.  Yes, Pascal has
  33. a lower learning curve for this, and for that reason is a good
  34. teaching language.  However, C and C++ trade simplicity for expressive
  35. power, which has contributed much to the language's popularity, IMO.
  36.  
  37. >by abstraction?  C is one of the lowest-level languages there is, and C++
  38. >is just an object-oriented hack put on top of it.
  39.  
  40. This is a common problem: people not "getting" the philosophy of
  41. C/C++.  First, though, don't get me wrong by thinking that you "must"
  42. agree with C/C++'s philosophy.  I just mean to say that you really
  43. can't responsibly argue for or against C/C++ without first
  44. understanding its philosophy.
  45.  
  46. Anyway, my point is that C and C++ have the philosophy that they are
  47. just a tool, and it is up to the programmer to use them properly (or
  48. improperly, if they so wish).  Many languages attempt to force the
  49. programmer to write good programs, and they have some merit because of
  50. that.  Unfortunately, you frequently run into problems because the
  51. language designer's idea of a "good program" and yours differs.  The
  52. programmer ends up feeling stifled and overly constrained.  
  53.  
  54. On the other hand, C and C++ don't have much to say about how you
  55. write your program.  You'll find that pretty much every syntax rule of
  56. C/C++ has a solid, unrefuted basis in good design principles.
  57. Controversial tools like goto are provided for those that want them.
  58. But notice that even goto is constrained: you can't jump outside a
  59. function, something that is more-or-less universally agreed to be a
  60. Good Thing.  For those situations where you really do want to break
  61. function barriers, there is setjmp/longjmp.  Both tools are dangerous
  62. but useful -- they're there for when you need them, and you can ignore
  63. them when you don't need them.
  64.  
  65. In contrast, consider Old BASIC.  Why does no one disagree that it was
  66. a bad language?  Because it didn't provide the tools necessary to
  67. write good programs, not because of the features it did provide.  As
  68. MS and others extended BASIC with functions, looping constructs, local
  69. scoped variables, modules and such, BASIC began to lose some of its
  70. opposition, so that now there are thousands of respected professionals
  71. making their living with BASIC; specifically, VB.
  72.  
  73. The moral?  C/C++ doesn't necessarily encourage good programming, but
  74. only because it doesn't enforce much of anything related to style.  I
  75. like the C/C++ world's solution to having tools to look over your
  76. shoulder: make them completely external to the language, like lint.
  77. That way, you have both automated protection as well as freedom of
  78. design.  If the checks are built into the language, you don't have
  79. many choices at all: do it the tool's way or don't do it at all.
  80.  
  81. >C++ is badly designed.  For example, Function pointer will return an
  82. >integer, takes two ints as parameters.  In C/C++
  83. >   typedef (int*)(int a, int b) MyFuncType;
  84. >   MyFuncType MyFunc;
  85. >in Oberon
  86. >   TYPE
  87. >      MyFuncType:FUNCTION( a, b:INTEGER ):INTEGER;
  88. >   VAR
  89. >      MyFunc:MyFuncType;
  90. >Which do you think looks more readable?
  91.  
  92. Again, this is a philosophical distinction.  C/C++'s function pointers
  93. are low-level, true hardware pointers, not abstracted handles or some
  94. such.  Could you, for example, assign a raw address to the Oberon
  95. sample?  You can in C/C++, because they're directly analogous to the
  96. underlying machine structures.
  97.  
  98. I'm not saying that function pointers couldn't be made better, as your
  99. Oberon code shows, just that C/C++ wasn't designed with that in mind.
  100. That doesn't mean that it was poorly designed, either.
  101.  
  102. To summarize: you can't argue about syntax rules without understanding
  103. and taking into account the design goals behind them.  In that
  104. respect, I think C/C++ is okay -- it lives up to its design goals.
  105. Now, if those design goals don't work for you, then you have a problem
  106. all right, but only to the extent that you must find a language that
  107. has "better" design goals.
  108.  
  109. To summarize the summary: You don't dislike C/C++, its design goals
  110. just aren't compatible with yours.
  111.  
  112. = Warren --
  113.